package com.grass.p019lv.activity;

import android.os.Bundle;
import android.view.View;
import androidx.recyclerview.widget.LinearLayoutManager;
import com.alibaba.android.arouter.facade.Postcard;
import com.alibaba.android.arouter.launcher.ARouter;
import com.androidsa.bttsddka.R;
import com.androidx.p013lv.base.Constance;
import com.androidx.p013lv.base.bean.VarietyBean;
import com.androidx.p013lv.base.bean.VarietyListBean;
import com.androidx.p013lv.base.http.BaseRes;
import com.androidx.p013lv.base.http.HttpUtils;
import com.androidx.p013lv.base.http.UrlManager;
import com.androidx.p013lv.base.http.callback.HttpCallback;
import com.androidx.p013lv.base.interfaces.Key;
import com.androidx.p013lv.base.listener.ItemClickListener;
import com.androidx.p013lv.base.p015ui.LazyFragment;
import com.androidx.p013lv.base.utils.NetUtil;
import com.grass.p019lv.adapter.AdapterVariety;
import com.grass.p019lv.databinding.FragmentVarietyBinding;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;

/* renamed from: com.grass.lv.activity.VarietyFragment */
public class VarietyFragment extends LazyFragment<FragmentVarietyBinding> implements View.OnClickListener, OnRefreshListener {
    String HTTP_TAG = "carefullyList";
    AdapterVariety adapter;

    @Override // com.androidx.p013lv.base.p015ui.LazyFragment
    public int setFragmentView() {
        return R.layout.fragment_variety;
    }

    public static VarietyFragment newInstance() {
        Bundle bundle = new Bundle();
        VarietyFragment varietyFragment = new VarietyFragment();
        bundle.putSerializable("", "");
        varietyFragment.setArguments(bundle);
        return varietyFragment;
    }

    @Override // com.androidx.p013lv.base.p015ui.LazyFragment
    public void initViews() {
        ((FragmentVarietyBinding) this.binding).refresh.setOnRefreshListener(this);
        ((FragmentVarietyBinding) this.binding).refresh.setEnableLoadMore(false);
        ((FragmentVarietyBinding) this.binding).recycler.setLayoutManager(new LinearLayoutManager(getActivity()));
        this.adapter = new AdapterVariety();
        ((FragmentVarietyBinding) this.binding).recycler.setAdapter(this.adapter);
        this.adapter.setItemListener(new ItemClickListener() {
            /* class com.grass.p019lv.activity.VarietyFragment.C29201 */

            @Override // com.androidx.p013lv.base.listener.ItemClickListener
            public void onItemClick(View view, int i) {
                if (!VarietyFragment.this.isOnClick()) {
                    Postcard withString = ARouter.getInstance().build(Constance.VARIETY_INFO_ACTIVITY).withString(Key.TXT, ((VarietyBean) VarietyFragment.this.adapter.getDataInPosition(i)).getChoiceTitle()).withInt("type", ((VarietyBean) VarietyFragment.this.adapter.getDataInPosition(i)).getChoiceId()).withString(Key.DESC, ((VarietyBean) VarietyFragment.this.adapter.getDataInPosition(i)).getDesc());
                    withString.withString("data", VarietyFragment.this.adapter.getDomain() + ((VarietyBean) VarietyFragment.this.adapter.getDataInPosition(i)).getBackground()).navigation();
                }
            }
        });
        ((FragmentVarietyBinding) this.binding).statusLayout.setOnRetryListener(new View.OnClickListener() {
            /* class com.grass.p019lv.activity.VarietyFragment.View$OnClickListenerC29212 */

            public void onClick(View view) {
                VarietyFragment.this.getInfo();
            }
        });
        getInfo();
    }

    /* access modifiers changed from: package-private */
    public void getInfo() {
        AdapterVariety adapterVariety = this.adapter;
        if (!(adapterVariety == null || adapterVariety.getData() == null || this.adapter.getData().size() <= 0)) {
            this.adapter.clear();
        }
        if (!NetUtil.isNetworkAvailable()) {
            ((FragmentVarietyBinding) this.binding).statusLayout.showNoNet();
            return;
        }
        ((FragmentVarietyBinding) this.binding).statusLayout.showLoading();
        HttpUtils.getInsatance().get(UrlManager.getInsatance().carefullyList(), new HttpCallback<BaseRes<VarietyListBean>>(this.HTTP_TAG) {
            /* class com.grass.p019lv.activity.VarietyFragment.C29223 */

            public void onLvSuccess(BaseRes<VarietyListBean> baseRes) {
                ((FragmentVarietyBinding) VarietyFragment.this.binding).statusLayout.hideLoading();
                ((FragmentVarietyBinding) VarietyFragment.this.binding).refresh.finishRefresh();
                if (baseRes.getCode() != 200) {
                    ((FragmentVarietyBinding) VarietyFragment.this.binding).statusLayout.showError();
                } else if (baseRes.getData() == null || baseRes.getData().getList() == null || baseRes.getData().getList().size() <= 0) {
                    ((FragmentVarietyBinding) VarietyFragment.this.binding).statusLayout.showEmpty();
                } else {
                    VarietyFragment.this.adapter.setDomain(baseRes.getData().getDomain());
                    VarietyFragment.this.adapter.setData(baseRes.getData().getList());
                }
            }
        });
    }

    public void onClick(View view) {
        if (isOnClick()) {
        }
    }

    @Override // com.scwang.smartrefresh.layout.listener.OnRefreshListener
    public void onRefresh(RefreshLayout refreshLayout) {
        getInfo();
    }

    @Override // androidx.fragment.app.Fragment, com.gyf.immersionbar.components.ImmersionFragment
    public void onDestroy() {
        super.onDestroy();
        HttpUtils.getInsatance().cancelTag(this.HTTP_TAG);
    }
}
